package com.cloud.rest.api;

import java.util.List;
import java.util.Map;
import java.util.Set;

public class Action {

	private final String name;
	private final List<String> reqParam;
	private final Map<String,String> paramRules;
	
	public Action(String name, 
			      List<String> reqParam, 
			      Map<String,String> paramRules) {
		this.name = name;
		this.reqParam = reqParam;
		this.paramRules = paramRules;
	}
	
	public boolean isParamValid(Set<String> param) {
		boolean containsRequiredParams = param.containsAll(this.reqParam);
		if (paramRules != null) {
			for (String p : param) {
				if(!p.matches(paramRules.get(p)))
					return false;
			}
		}
		return containsRequiredParams;
	}
	
	public String getName() {
		return this.name;
	}
	
	public List<String> getRequiredParams(){
		return this.reqParam;
	}
}
